package cn.wikiflyer.beikang.act.user.utils;

import cn.wikiflyer.beikang.R;
import cn.wk.libs4a.utils.WKPhotoUtil;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.PopupWindow;
import android.widget.LinearLayout.LayoutParams;

public class ChoosePay  {
	
	private Context mContext;
	private Activity activity;
	private ChooseListener listener1,listener2,listener3;
	public ChoosePay(Activity context){
		this.mContext = context;
		this.activity = context;
	}
	/**
	 * 弹出选取照片对话框
	 */
	private PopupWindow popSelection; // 更换头像的弹出框

	public void showSelection(View view) {
		View sView = LayoutInflater.from(mContext).inflate(R.layout.pop_takepay_lay, null);
		sView.findViewById(R.id.touming).setOnClickListener(new SelectionListener());
		sView.findViewById(R.id.viewWithRadio1).setOnClickListener(new SelectionListener());
		sView.findViewById(R.id.viewWithRadio2).setOnClickListener(new SelectionListener());
		sView.findViewById(R.id.viewWithRadio3).setOnClickListener(new SelectionListener());
		sView.findViewById(R.id.btn_selection_cancel).setOnClickListener(new SelectionListener());
		popSelection = new PopupWindow(sView, LayoutParams.MATCH_PARENT,
				LayoutParams.MATCH_PARENT);
		popSelection.setBackgroundDrawable(new BitmapDrawable());
		popSelection.setOutsideTouchable(true);
		popSelection.setFocusable(true);
		popSelection.showAsDropDown(view, 0, 0);
	}
	public void setChooseListener(ChooseListener l1,ChooseListener l2,ChooseListener l3){
		this.listener1 = l1;
		this.listener2 = l2;
		this.listener3 = l3;
	}
	
	
	/**选择点击事件
	 */
	class SelectionListener implements OnClickListener{
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.tuisong_btn:
				break;
			case R.id.viewWithRadio1:
				listener1.choose();
				break;
			case R.id.viewWithRadio2:
				listener2.choose();
				break;
			case R.id.viewWithRadio3:
				listener3.choose();
				break;
			case R.id.btn_selection_cancel:
				break;
			default:
				break;
			}
			if (popSelection != null && popSelection.isShowing()) {
				popSelection.dismiss();
			}
		}
	}
	public interface ChooseListener{
		public void choose();
	}

}
